package com.lb.optional;

import java.util.Optional;

/**
 * @version 1.0
 * @Author: Edward
 * @Date: 2020/11/10 9:42
 * @Description: Optional
 */
public class OptionalTest {
    public static void main(String[] args) {
        String name = null;
        Optional<String> optional = Optional.ofNullable(name);
        optional.ifPresent(item -> System.out.println(item));
//        System.out.println(optional.ifPresent(item -> System.out.println(item)););

        String s = Optional.ofNullable(name).orElse("d");
        System.out.println(" s => " + s);
    }
}
